<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Input;

class OnlyNewsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
         /*$id=Input::get('id');
         $echo $id;
             $json_arr = array("userid"=>$id);

           $o="";
            foreach ($json_arr as $k=>$v)
            {
                 $o.= "$k=".urlencode($v)."&";
            }
           $json_data=substr($o,0,-1);
         $url="192.168.0.21:8080/test/blog/".$id;
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url); /*获取URL的内容*/
        /*curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_HTTPGET,true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);/*获取的内容不输出*/
        /*$content = curl_exec($ch);/*输出获取的内容*/
         //  $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
        //curl_close($ch);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $id=substr($id,8);
        $url="192.168.0.21:8080/test/blog/".$id;
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url); /*获取URL的内容*/
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_HTTPGET,true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);/*获取的内容不输出*/
        $content = curl_exec($ch);/*输出获取的内容*/
         //  $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
        curl_close($ch);
        $content = json_decode($content);
        $title=$content->title;
        $author="[".$content->author."]";
        $body = $content->content;
        return view('web.bd_news',['title'=>$title,'author'=>$author,'newstext'=>$body]);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
